package com.ruoyi.channel.controller;

import com.ruoyi.channel.domain.ChannelApply;
import com.ruoyi.channel.service.IChannelApplyService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 渠道商审核Controller
 * 
 * @author ruoyi
 * @date 2025-04-09
 */
@RestController
@RequestMapping("/channelApply/channelApply")
public class ChannelApplyController extends BaseController
{
    @Autowired
    private IChannelApplyService channelApplyService;

    /**
     * 查询渠道商审核列表
     */
    @PreAuthorize("@ss.hasPermi('channelApply:channelApply:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChannelApply channelApply)
    {
        startPage();
        List<ChannelApply> list = channelApplyService.selectChannelApplyList(channelApply);
        return getDataTable(list);
    }

    /**
     * 导出渠道商审核列表
     */
    @PreAuthorize("@ss.hasPermi('channelApply:channelApply:export')")
    @Log(title = "渠道商审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChannelApply channelApply)
    {
        List<ChannelApply> list = channelApplyService.selectChannelApplyList(channelApply);
        ExcelUtil<ChannelApply> util = new ExcelUtil<ChannelApply>(ChannelApply.class);
        util.exportExcel(response, list, "渠道商审核数据");
    }

    /**
     * 获取渠道商审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('channelApply:channelApply:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(channelApplyService.selectChannelApplyById(id));
    }

    /**
     * 新增渠道商审核
     */
    @PreAuthorize("@ss.hasPermi('channelApply:channelApply:add')")
    @Log(title = "渠道商审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChannelApply channelApply)
    {
        return toAjax(channelApplyService.insertChannelApply(channelApply));
    }

    /**
     * 修改渠道商审核
     */
    @PreAuthorize("@ss.hasPermi('channelApply:channelApply:edit')")
    @Log(title = "渠道商审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChannelApply channelApply) throws IOException {
        return toAjax(channelApplyService.updateChannelApply(channelApply));
    }

    /**
     * 删除渠道商审核
     */
    @PreAuthorize("@ss.hasPermi('channelApply:channelApply:remove')")
    @Log(title = "渠道商审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(channelApplyService.deleteChannelApplyByIds(ids));
    }
}
